<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="res/js/vue.min.js"></script>
    <script type="text/javascript" src="res/js/axios.min.js"></script>
</head>
<body>
    <button onclick="getContextPath()">按钮</button>
    <div id="app">
        <h1>{{path}}</h1>
        <a href="hello">hello</a><br/>
        <button @click="fun1">异步请求</button><br/>
        <button @click="fun2">getSession</button>
    </div>


</body>
<script type="text/javascript">
    function getContextPath(){
        var pathName = document.location.pathname;
        var index = pathName.substr(1).indexOf("/");
        var result = pathName.substr(0,index+1);
        alert(result);
    }
    new Vue({
        el:"#app",
        data:{
            path:"abc"
        },
        methods:{
            fun1:function () {
                alert("执行方法");
                axios.get('getText')
                    .then(function (value) {
                        alert(value.data);
                    }).catch(function (reason) {
                        alert("失败");
                })
            },
            fun2:function () {
                axios.get('getSession')
                    .then(function (value) {
                        console.log(value.data);
                    })
            }
        }
    });

</script>
</html>